{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-10-23T07:26:37.648531Z",
     "start_time": "2020-10-23T07:26:37.120514Z"
    }
   },
   "outputs": [],
   "source": [
    "import urllib.request\n",
    "import numpy\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn import ensemble\n",
    "from sklearn.metrics import mean_squared_error\n",
    "import pylab as plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-10-23T10:42:02.465223Z",
     "start_time": "2020-10-23T10:42:00.121755Z"
    }
   },
   "outputs": [],
   "source": [
    "url='http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'\n",
    "data=urllib.request.urlopen(url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-10-23T10:43:32.891442Z",
     "start_time": "2020-10-23T10:43:32.888360Z"
    }
   },
   "outputs": [],
   "source": [
    "xlist=[]\n",
    "labels=[]\n",
    "names=[]\n",
    "firstline=False\n",
    "for lin in data:\n",
    "    print(lin)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-10-23T10:43:35.262383Z",
     "start_time": "2020-10-23T10:43:35.255326Z"
    }
   },
   "outputs": [],
   "source": [
    "for line in data:\n",
    "    if firstline:\n",
    "        names=line.strip().split(b';')\n",
    "        firstline=False\n",
    "    else:\n",
    "        row=line.strip().split(b';')\n",
    "        print(row)\n",
    "#         labels.append(float(row[-1]))\n",
    "        row.pop()\n",
    "        floatrow=[float(num) for num in row]\n",
    "        xlist.append(floatrow)\n",
    "nrows=len(xlist)\n",
    "# ncols=len(xlist[1])\n",
    "x=numpy.array(xlist)\n",
    "x=numpy.array(labels)\n",
    "winenames=numpy.array(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
